package cn.consult.config.utils;

import cn.consult.netty.BootNettyChannelInboundHandlerAdapter;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;

public class BootNettyChannelInitializer <SocketChannel> extends ChannelInitializer<Channel> {

    @Override
    protected void initChannel(Channel channel) throws Exception {
        // ChannelOutboundHandler，依照逆序执行
        channel.pipeline().addLast("encoder", new NettyMessageEncoder());

        // 属于ChannelInboundHandler，依照顺序执行
        channel.pipeline().addLast("decoder", new NettyMessageDecoder());
        /**
         * 自定义ChannelInboundHandlerAdapter
         */
        channel.pipeline().addLast(new BootNettyChannelInboundHandlerAdapter());
    }
}
